﻿#pragma strict

public var moveVelocity: float;
public var jumHeight: float;
public var scaleJum: float;
public var isFalling = false;

function Start () {
	moveVelocity = 0.05;
	jumHeight = 5.5;
	scaleJum = 3;
}

function Update () {
	if(isFalling == true)
		return;
	KeyPress();
}
function KeyPress(){
	if(Input.GetKey(KeyCode.UpArrow)&&Input.GetKey(KeyCode.LeftArrow))
	{
		isFalling = true;
		rigidbody.velocity.y = jumHeight;
		rigidbody.velocity.x = -scaleJum;
	}
	else if(Input.GetKey(KeyCode.UpArrow)&&Input.GetKey(KeyCode.RightArrow))
	{
		isFalling = true;
		rigidbody.velocity.y = jumHeight;
		rigidbody.velocity.x = scaleJum;		
	}
	else if(Input.GetKeyDown(KeyCode.UpArrow))
	{
		isFalling = true;
		rigidbody.velocity.y = jumHeight;
	}
	else if(Input.GetKey(KeyCode.RightArrow)){
		transform.Translate(Vector3(moveVelocity,0,0));
	}
	else if(Input.GetKey(KeyCode.LeftArrow)){
		transform.Translate(Vector3(-moveVelocity,0,0));
	}
}
function OnCollisionEnter (col : Collision)
{
	if(col.gameObject.name == "Bottom" ||col.gameObject.name =="TopNormalCollider")
    	isFalling = false;
    	
    if(col.gameObject.name == "Goal"){
    	Debug.Log("Goal!");
    }
    
    if(col.gameObject.name == "DangerCollider"){
    	Debug.Log("Game Over");
    }
    	
}